
#[tokio::main]
async fn main() {
    let nums = vec![1,2,3,4];
    let res = number_of_arithmetic_slices(nums);
    println!("res:{}",res);
}

pub fn number_of_arithmetic_slices(nums: Vec<i32>) -> i32 {
    if nums.len() < 3{
        return 0
    }
    let mut cha = nums[0]-nums[1];
    let mut res = vec![];
    let mut i = 0;
    let mut j = 0;
    while i<nums.len()-1 {
        if nums[i] - nums[i+1] == cha{
            j +=1 ;
        }else{
            cha = nums[i] - nums[i+1];
            if j >= 2 {
                res.push(j+1)
            }
            j = 1
        }
        i+=1
    }
    if j >= 2 {
        res.push(j+1)
    }
    let mut cha = 0
    return cha
}